package top.lyc829.days.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.lyc829.days.bean.Event;
import top.lyc829.days.dao.EventDao;

import java.util.List;

@Service
public class EventService {
    @Autowired
    EventDao eventDao;

    public void addEvent(Event event) {
        eventDao.save(event);
    }

    public List<Event> getAllEventsByUserId(int userId) {
        return eventDao.findAllByUserId(userId);
    }

    @Transactional
    public void deleteByUserIdAAndCreateTime(int userId, Long creatTime) {
        eventDao.deleteByUserIdAndCreateTime(userId, creatTime);
    }

    public Event findByUserIdAAndCreateTime(int userId, Long createTime) {
        return eventDao.findByUserIdAndCreateTime(userId, createTime);
    }


}
